﻿

namespace LxCFD
{
    public class MaxMonitor : UserMonitorBase
    {
        public override void RunMonitor()
        {
            IsCurrentExist = false;
            CurrentResult = double.MinValue;
            RunStatistic();
        }
        public override void CalCellValue(FvZone selectedZone, double[] array, int taskIndex)
        {
            double localMax = CurrentResult;
            selectedZone.InnerIndex.CellIDs.GetSeg(out int i1, out int endp1, taskIndex);
            for (; i1 < endp1; i1++)
            {
                ref double d = ref array[i1];
                if (d > localMax)
                {
                    localMax = d;
                }
            }
            ThreadsMath.KeepMax(ref CurrentResult, localMax);
        }
        public override void CalFaceValue(FvZone selectedZone, FvThread selectedThread, double[] array, int taskIndex)
        {
            double localMax = CurrentResult;
            selectedThread.ThreadIndex.CellIDs.GetSeg(out int i1, out int endp1, taskIndex);
            for (; i1 < endp1; i1++)
            {
                ref double d = ref array[i1];
                if (d > localMax)
                {
                    localMax = d;
                }
            }
            ThreadsMath.KeepMax(ref CurrentResult, localMax);
        }
    }
}

